home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / hexedit.fpl < prev    next >
Text File  |  1995-07-18  |  1KB  |  41 lines

  1.  
  2. export int he_oldval;
  3. export int he_oldcount=-2;
  4.  
  5. export void HexEdit(string input)
  6. {
  7.   if (strlen(input)==1) {
  8.     int val=strtol(input, 16);
  9.     int oldchar=0, oldinsert=ReadInfo("insert_mode");
  10.     if (val!=0 || input[0]=='0') {
  11.       oldchar=GetChar();
  12.       if (he_oldcount==ReadInfo("counter")-1) {
  13.         he_oldval=(oldchar&240)+val;
  14.         he_oldcount=-2;
  15.       } else {
  16.         he_oldval=(oldchar&15)+(val<<4);
  17.         he_oldcount=ReadInfo("counter");
  18.       }
  19.       if (he_oldval!=oldchar) {
  20.         Visible(0);
  21.         input[0]=he_oldval;
  22.         SetInfo(-1, "insert_mode", 0);
  23.         Clean(joinstr("Output(\"",CConvertString(input),"\");"));
  24.         SetInfo(-1, "insert_mode", oldinsert);
  25.         if (he_oldcount!=-2)
  26.           CursorLeft();
  27.         else if (Isnewline(he_oldval))
  28.           Delete();
  29.       } else if (he_oldcount==-2)
  30.         CursorRight();
  31.       ReturnStatus("");
  32.       return(1);
  33.     }
  34.   }
  35.   return(0);
  36. }
  37.  
  38. ConstructInfo("hex_edit", "", "", "LB(system)", "", 0, 1, 0);
  39. Hook("Output", "HexEdit", "hex_edit");
  40.  
  41.